home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
fscompr
/
fscomprf.ctl
< prev
next >
Wrap
Text File
|
1997-12-24
|
8KB
|
306 lines
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Begin VB.UserControl FSComprFile
ClientHeight = 585
ClientLeft = 0
ClientTop = 0
ClientWidth = 3690
ScaleHeight = 585
ScaleWidth = 3690
ToolboxBitmap = "FSComprFile.ctx":0000
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 200
Left = 960
Top = 120
End
Begin ComctlLib.ProgressBar pbStatus
Height = 375
Left = 120
TabIndex = 0
Top = 120
Width = 3015
_ExtentX = 5318
_ExtentY = 661
_Version = 327682
Appearance = 1
End
End
Attribute VB_Name = "FSComprFile"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Enum fsCompressionLevel
fsCmpNoCompression
fsCmpFastest
fsCmpLev2
fsCmpLev3
fsCmpLev4
fsCmpLev5
fsCmpDefault
fsCmpLev7
fsCmpLev8
fsCmpMaximum
End Enum
Enum fsResultStatus
' ZLIB specific
fsResOk = 0
fsResErrno = -1
fsResStreamError = -2
fsResDataError = -3
fsResMemError = -4
fsResBufError = -5
fsResVersionError = -6
' FSZlib specific
fsResErrInputFile = -200 '
fsResErrOutputFile = -201
fsResErrBackupFile = -202 ' error opening file to backup
' OCX specific
fsResMissingInputFileName = -1500
fsResMissingOutputFileName = -1501
' fsResMissingBackupFileName = -1502
' fsResMissingDisk = -1503
' fsResReadOnlyDisk = -1504
' fsGenericRemovableDiskError = -1505
End Enum
' current percent
Private PerCent As Integer
Private InFile As String, OutFile As String
Private Lev As fsCompressionLevel
'Private BackFile As String, BackDrive As String
' result of last action
Private pResultStatus As fsResultStatus
' EVENTS ---------------------------------
'Public Event AskForDisk(DiskNo As Integer)
Private Sub UserControl_Initialize()
' pbStatus.Value = 100
End Sub
Private Sub UserControl_Resize()
pbStatus.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Public Property Get Value() As Integer
Attribute Value.VB_Description = "Position of the progress bar (between 0 and 100)"
Value = pbStatus.Value
End Property
Public Property Let Value( _
ByVal NewValue As Integer)
pbStatus.Value = NewValue
PropertyChanged "Value"
End Property
Private Sub Timer1_Timer()
If PerCent <> modCompress.gPerCent Then
PerCent = modCompress.gPerCent
pbStatus.Value = PerCent
End If
End Sub
Private Sub UserControl_InitProperties()
Level = fsCmpDefault
InputFile = ""
OutputFile = ""
' BackupFile = ""
' BackupDrive = "A:"
End Sub
Public Sub Compress()
If Trim$(OutFile) = "" Then
pResultStatus = fsResMissingOutputFileName
Exit Sub
End If
If Trim$(InFile) = "" Then
pResultStatus = fsResMissingInputFileName
Exit Sub
End If
PerCent = 0
pbStatus.Value = 0
Timer1.Enabled = True
pResultStatus = CompressFile(OutFile, InFile, Lev)
Timer1.Enabled = False
PerCent = 0
pbStatus.Value = 0
End Sub
Public Sub Decompress()
If Trim$(OutFile) = "" Then
pResultStatus = fsResMissingOutputFileName
Exit Sub
End If
If Trim$(InFile) = "" Then
pResultStatus = fsResMissingInputFileName
Exit Sub
End If
PerCent = 0
pbStatus.Value = 0
Timer1.Enabled = True
pResultStatus = DecompressFile(OutFile, InFile)
Timer1.Enabled = False
PerCent = 0
pbStatus.Value = 0
End Sub
Public Property Get InputFile() As String
Attribute InputFile.VB_Description = "Path of the file to be compressed (by Compress) or decompressed (by Decompress)"
Attribute InputFile.VB_ProcData.VB_Invoke_Property = ";Compression"
InputFile = InFile
End Property
Public Property Let InputFile(ByVal vNewInputFile As String)
InFile = vNewInputFile
PropertyChanged "InputFile"
End Property
Public Property Get OutputFile() As String
Attribute OutputFile.VB_Description = "Path of the compressed file (by Compress) of decompressed file (by Decompress)"
Attribute OutputFile.VB_ProcData.VB_Invoke_Property = ";Compression"
OutputFile = OutFile
End Property
Public Property Let OutputFile(ByVal vNewOutputFile As String)
OutFile = vNewOutputFile
PropertyChanged "OutputFile"
End Property
'Public Property Get BackupFile() As String
' BackupFile = BackFile
'End Property
'Public Property Let BackupFile(ByVal vNewBackupFile As String)
' BackFile = vNewBackupFile
' PropertyChanged "BackupFile"
'End Property
'Public Property Get BackupDrive() As String
' BackupDrive = BackDrive
'End Property
'Public Property Let BackupDrive(ByVal vNewBackDrive As String)
' BackDrive = vNewBackDrive
' PropertyChanged "BackupDrive"
'End Property
Public Property Get Level() As fsCompressionLevel
Attribute Level.VB_Description = "Compression level (0-9)"
Attribute Level.VB_ProcData.VB_Invoke_Property = ";Compression"
Level = Lev
End Property
Public Property Let Level(ByVal vNewValue As fsCompressionLevel)
Lev = vNewValue
PropertyChanged "Level"
End Property
Public Property Get ResultStatus() As fsResultStatus
Attribute ResultStatus.VB_Description = "Result of the last operation (0 = OK)"
Attribute ResultStatus.VB_ProcData.VB_Invoke_Property = ";Compression"
ResultStatus = pResultStatus
End Property
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Level", Level, 6
PropBag.WriteProperty "InputFile", InputFile, ""
PropBag.WriteProperty "OutputFile", OutputFile, ""
' PropBag.WriteProperty "BackupFile", BackupFile, ""
' PropBag.WriteProperty "BackupDrive", BackupDrive, "A:"
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Level = PropBag.ReadProperty("Level", 6)
InputFile = PropBag.ReadProperty("InputFile", "")
OutputFile = PropBag.ReadProperty("OutputFile", "")
' BackupFile = PropBag.ReadProperty("BackupFile", "")
' BackupDrive = PropBag.ReadProperty("BackupDrive", "A:")
End Sub
Public Sub ShowAboutBox()
Attribute ShowAboutBox.VB_UserMemId = -552
dlgInfo.Show vbModal
Unload dlgInfo
Set dlgInfo = Nothing
End Sub
'Public Sub Backup()
' ' backups a file to one or more removable disks disks
' Dim Remaining As Long, ToProcess As Long
'
' If Trim$(BackFile) = "" Then
' pResultStatus = fsResMissingBackupFileName
' Exit Sub
' End If
'
' ' ask for disk
' RaiseEvent AskForDisk(1)
'
' ' wipes the disk
'
'
'
' ' opens the file
' On Error Resume Next
' Open BackFile For Binary As #1
' If Err.Number <> 0 Then
' pResultStatus = fsResErrBackupFile
' Exit Sub
' End If
'
' Remaining = LOF(1)
'
'
'
'End Sub
Public Property Get Appearance() As AppearanceConstants
Attribute Appearance.VB_ProcData.VB_Invoke_Property = ";Aspetto"
Appearance = pbStatus.Appearance
End Property
Public Property Let Appearance(ByVal vNewValue As AppearanceConstants)
pbStatus.Appearance = vNewValue
PropertyChanged "Appearance"
End Property
Public Property Get BorderStyle() As ComctlLib.BorderStyleConstants
Attribute BorderStyle.VB_ProcData.VB_Invoke_Property = ";Aspetto"
BorderStyle = pbStatus.BorderStyle
End Property
Public Property Let BorderStyle(ByVal vNewValue As ComctlLib.BorderStyleConstants)
pbStatus.BorderStyle = vNewValue
PropertyChanged "BorderStyle"
End Property